package com.czy.workflow.core.model.vo;

import com.czy.workflow.core.model.FlowBranch;
import com.czy.workflow.core.model.FlowNode;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
public class FlowNodeVO  implements Serializable {

    String nodeId;

    String nodeName;

    List<String> options = new ArrayList<>();

    public static FlowNodeVO build(FlowNode flowNode, List<FlowBranch> flowBranches){
        FlowNodeVO nodeVo = new FlowNodeVO();
        nodeVo.setNodeId(flowNode.getId());
        nodeVo.setNodeName(flowNode.getName());
        nodeVo.getOptions().clear();
        for(FlowBranch branch : flowBranches){
            nodeVo.getOptions().add(branch.getOption());
        }
        return nodeVo;
    }

}
